RWTH - Mindstorms NXT Toolbox

NXT_LSWrite

Writes the given data to a low speed (digital) sensor

Contents

Syntax

NXT_LSWrite(port, RXLength, data, ReplyMode)

NXT_LSWrite(port, RXLength, data, ReplyMode, handle)

Description

NXT_LSWrite(port, RXLength, data, ReplyMode) writes the given data to a low speed (digital) sensor of the given sensor port. The value port can be addressed by the symbolic constants SENSOR_1, SENSOR_2, SENSOR_3 and SENSOR_4 analog to the labeling on the NXT Brick. The value RXLength represents the data length of the expected receiving packet. By the ReplyMode one can request an acknowledgement for the packet transmission. The two strings 'reply' and 'dontreply' are valid.

NXT_LSWrite(port, RXLength, data, ReplyMode, handle) uses the given Bluetooth connection handle. This should be a serial handle on a PC system and a file handle on a Linux system.

If no Bluetooth handle is specified the default one (COM_GetDefaultNXT) is used.

For more details see the official LEGO Mindstorms communication protocol.

Note:

For LS communication on the NXT, data lengths are limited to 16 bytes per command. Rx Data Length MUST be specified in the write command since reading from the device is done on a master-slave basis.

Before using LS commands, the sensor mode has to be set to LOWSPEED_9V using the NXT_SetInputMode command.

Example

   RequestLen = 1;
   I2Cdata = hex2dec(['02'; '42']); % specific ultrasonic I²C command

   handle = COM_OpenNXT('bluetooth.ini','check');
   NXT_SetInputMode(SENSOR_1, 'LOWSPEED_9V', 'RAWMODE', 'dontreply');

   NXT_LSWrite(SENSOR_1, RequestLen, I2Cdata, 'dontreply', handle);

See also

NXT_SetInputMode, NXT_LSRead, NXT_LSGetStatus, COM_ReadI2C

Signature